/*
	关闭通道后可以一直从通道读到0
*/

package main

import (
	"log"
)

func isClosed(ch <-chan int) bool {
	select {
	case <-ch:
		println("ch:", <-ch)
		return true
	default:
	}

	return false
}

func main() {
	log.SetFlags(log.Lshortfile)

	ch := make(chan int)

	log.Println("is closed:", isClosed(ch))
	close(ch)

	//	isClosed(ch)
	func() {

		for isClosed(ch) {

		}

	}()
	log.Println("is closed:", isClosed(ch))

}
